@echo off
echo ========================================
echo CourseHub 微服务系统 Docker 部署脚本
echo ========================================

echo.
echo 1. 构建所有微服务镜像...
echo.

REM 构建共享组件
echo 构建 shared-components...
cd shared-components
call mvn clean install -DskipTests
cd ..

REM 构建用户管理服务
echo 构建 user-management-service...
docker build -f user-management-service/Dockerfile -t coursehub/user-management-service:latest .

REM 构建课程管理服务
echo 构建 course-management-service...
docker build -f course-management-service/Dockerfile -t coursehub/course-management-service:latest .

REM 构建练习管理服务
echo 构建 exercise-management-service...
docker build -f exercise-management-service/Dockerfile -t coursehub/exercise-management-service:latest .

REM 构建学习进度服务
echo 构建 learning-progress-service...
docker build -f learning-progress-service/Dockerfile -t coursehub/learning-progress-service:latest .

REM 构建API网关
echo 构建 api-gateway...
docker build -f api-gateway/Dockerfile -t coursehub/api-gateway:latest .

echo.
echo 2. 启动所有服务...
echo.

REM 启动所有服务
docker-compose up -d

echo.
echo 3. 等待服务启动...
echo.
timeout /t 30 /nobreak

echo.
echo 4. 检查服务状态...
echo.
docker-compose ps

echo.
echo ========================================
echo 部署完成！
echo.
echo 服务访问地址：
echo - Consul UI: http://localhost:8500
echo - API Gateway: http://localhost:8080
echo - MySQL: localhost:3306
echo.
echo 使用以下命令查看日志：
echo docker-compose logs -f [service-name]
echo.
echo 使用以下命令停止所有服务：
echo docker-compose down
echo ========================================

pause